<?php

namespace common\models\app;

use Yii;
use yii\db\AfterSaveEvent;

/**
 * This is the model class for table "{{%app_access_log}}".
 *
 * @property int $id
 * @property string $user_id 用户UID
 * @property string $device_id 设备ID
 * @property string $token_id 访问TokenID
 * @property string $ip IP
 * @property string $created_at 创建时间
 * @property string $updated_at 更新时间
 */
class AppAccessLog extends \common\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return '{{%app_access_log}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['user_id', 'device_id', 'token_id', 'ip', 'created_at', 'updated_at'], 'integer'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'user_id' => '用户UID',
            'device_id' => '设备ID',
            'token_id' => '访问TokenID',
            'ip' => 'IP',
            'created_at' => '创建时间',
            'updated_at' => '更新时间',
        ];
    }

    /**
     * @inheritdoc
     * @param AfterSaveEvent $event
     */
    public function afterInsert($event) {
        Yii::error($event->sender);
        $model = $event->sender;
        //Yii::error($event->changedAttributes, __METHOD__);
        Yii::error($model->attributes, __METHOD__);
        Yii::error($model->id, __METHOD__);
    }

}
